package com.lx.pc.utils;

import java.io.IOException;
import java.math.BigInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

public class BigIntegerDeserializer extends JsonDeserializer<BigInteger> {

	private static final Logger logger = LoggerFactory.getLogger(BigIntegerDeserializer.class);

	@Override
	public BigInteger deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
		String value = p.getValueAsString();
		try {
			return new BigInteger(value);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
		return null;
	}
}